﻿//RequestDelegate requestDelegate = context => context.Response.WriteAsync("hello world");
//WebApplicationBuilder applicationBuilder= WebApplication.CreateBuilder(args);
//WebApplication webApplication = applicationBuilder.Build();
//webApplication.Run(requestDelegate);
//webApplication.Run();

//WebApplication app = WebApplication.Create();
//app.Run(requestDelegate);
//app.Run();

//WebApplication app = WebApplication.Create(args);
//IApplicationBuilder appBuilder = app;
//appBuilder.Use(HelloMiddle);
//appBuilder.Use(WorldMiddle);
//app.Run();
//static RequestDelegate HelloMiddle(RequestDelegate next)
//{
//    return async (HttpContext context) =>
//        {
//            await context.Response.WriteAsync("hello ");
//            await next(context);
//        };
//};

//static RequestDelegate WorldMiddle(RequestDelegate next)
//=> context =>context.Response.WriteAsync("world");

//static async Task HelloMiddle(HttpContext context, RequestDelegate next)
//{yuio
//    await context.Response.WriteAsync("hello ");
//    await next(context);
//}

//static Task WorldMiddle(HttpContext context, RequestDelegate next)
//=> context.Response.WriteAsync("world");

using App.Middles;
using App.Models;
using App.Services;

//var builder = WebApplication.CreateBuilder(args);
//builder.Services.AddSingleton<IGreetingService, GreetingV3Service>();
////builder.Services.AddSingleton<GreetingMiddleware>();
//WebApplication webApplication = builder.Build();
//webApplication.UseMiddleware<GreetingV2Middleware>();
//webApplication.Run();


//var builder = WebApplication.CreateBuilder(args);
//builder.Services.AddSingleton<IGreetingService,GreetingV2Service>();
//builder.Services.Configure<Greeting>(builder.Configuration.GetSection("greeting"));
//WebApplication app = builder.Build();
//app.UseMiddleware<GreetingV2Middleware>();
//app.Run();


//var builder = WebApplication.CreateBuilder();
//builder.Services.AddSingleton<IGreetingService,GreetingService>();
//WebApplication app = builder.Build();
//app.MapGet("/greet", Greet);
//app.Run();

//static string Greet(IGreetingService service) => service.Greeting(DateTimeOffset.Now);

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<IGreetingService, GreetingService>();
//builder.Services.AddControllers();
builder.Services.AddControllersWithViews();

WebApplication app = builder.Build();
app.MapControllers();
app.Run();